import { createApp } from "vue";
import App from "./App.vue";
import router from "./router/index";
import { createPinia } from "pinia";
import { useUserStore } from "./store/user";
import axios from "./http/requst";
import "element-plus/dist/index.css";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import "./assets/style/cooldialog.less";
import "./assets/style/index.less"; // global css
import "./assets/style/public.less"; // global css
import "./assets/style/form.less"; // global css
import "./assets/style/table.less"; // global css
import "./assets/icon/iconfont.css";
import converData from "./utils/converData";
import coolConfirm from "./utils/coolConfirm";
import regRule from "./utils/regRule";

const app = createApp(App);
const pinia = createPinia();

app.use(ElementPlus, {
  locale: zhCn, // 一定要加上，不然无效
});
app.config.globalProperties.$converData = converData;
app.config.globalProperties.$coolConfirm = coolConfirm;
app.config.globalProperties.$regRule = regRule;
app.config.globalProperties.$axios = axios;
// 拉完数据再挂载，保证首屏渲染时信息已是最新
app.use(router).use(pinia);
const userStore = useUserStore();
app.config.globalProperties.$userStore = userStore;

//每次刷新页面获取一下用户信息再加载
userStore.getUserInfo().finally(() => {
  app.mount("#app");
});
